 function showIssueUpdateWindow (issueRowData){
	      var issueUpdateWin;
	 	  var issueCommentStore   = CRM.commons.createStore('issueCommentid', CRM.SPComp.commentDataArray, 'issueComment/showComments?issueId='+issueRowData.get('issueId'));
	 	  var issueCategoryStore   = CRM.commons.createComboStore('issueCategoryStoreid','issueComment/issueCommentReqCombo','issueCategory');
	 	  var issuePriorityStore  = CRM.commons.createComboStore('issuepriorityStoreid','issueComment/issueCommentReqCombo','issuePriority');
		  var issueStatusStore    = CRM.commons.createComboStore('issueStatusStoreid','issueComment/issueCommentReqCombo','issueStatus');
		  var issueComplexityStore = CRM.commons.createComboStore('issueComplextityStoreid','issueComment/issueCommentReqCombo','issueComplexity');
		  var issueResolutionStore = CRM.commons.createComboStore('issueResolutionStoreid','issueComment/issueCommentReqCombo','issueResolution');
		  var assignedToStore = new Ext.data.JsonStore({ 
				id		: 'assignedToStore', 
				root    : 'data',
				fields  : [
								{
									name    : 'name',   
									mapping : 'fieldValue'  
								},
							    {
							        name    : 'id',
							         mapping : 'id'
								}
								
						],
				proxy 	: new Ext.data.HttpProxy({
				method	: 'GET',
				url	  	: 'issueComment/issueAssignedTo?projectId='+issueRowData.get('issueProjectId')
				}),
				remoteSort : false
			}); 
		  
		  var  tpl = new Ext.XTemplate(
				 
				'<div style="background-color:#B3BCCC;"  style="margin-top:10px; height:100px" ><tpl for=".">',
  		        '<p >&nbsp;', 
  		        '<span><b>Updated By&nbsp;:</b>&nbsp;</span><span ><b>{assignedTo}<b></span>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;',
  		        '<span><b>Date&nbsp;:</b>&nbsp;</span><span ><b>{updatedAt}</b></span>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;', 
  		        '<span><b>Status&nbsp;:</b>&nbsp;</span><span><b>{status}<b></span>&nbsp;', 
  		        '<br>', 
		        '<p >&nbsp;&nbsp;&nbsp;', 
  		         '<div align="justify" style ="background-color:#B3BCCC;margin:10px 5px;width:100%;height:80px;top:100px;border-bottom:4px solid gray;overflow: scroll;"><span><b >Comment :</b>&nbsp;</span><b>{comment}<b></div>',
  		         '</tpl></div>'); 
		   

		  
		 var issueUpdate ={
				  xtype       : 'fieldset',
				  id          : 'issueUpdate',
				  frame       : true,
				  border      : false,
				  width       :  590,
				  items       :[
				                  {
				                	   xtype        :'hidden',
				                	   id           :'issueId',
				                	   fieldLabel   :'IssueId'
				                  } ,
				                  {
				                	   xtype        :'hidden',
				                	   id           :'issueProjectId',
				                	   fieldLabel   :'Issue ProjectId'
				                	   
				                  },
				                  {
				                	    xtype        : 'textarea',
				                	    id           : 'issueReason',
				                	    fieldLabel   : 'Issue Details',
				                	    width        : '421',
				                	    height       : 70
				                   },
				                   {
				                	   xtype       : 'compositefield',
				                	   fieldLabel  : 'Category',
				                	   items       : [
				                	                    {
				                	                	    xtype          : 'combo',
				                	                	    id             : 'category',
				                	                	    value          : 'SELECT',
				                	                	    width          : '170',
				                	                	    store          : issueCategoryStore,
					     		   		     		   	 	displayField   : 'name',
					     	 	   		     		   	 	valueField     : 'id',
					      		   		     		   	 	triggerAction  : 'all',
					     		   		     		   	 	typeAhead      : false,
					     		   		     		        editable	   : false,
					     		   		     		        listeners      :{select:function(){
				                	                	                             bindValue('category','categoryId');
				                	                                                     }
				                	                                          }
					     		   		     		         
					     		   		     		    },
					     		   		     		    {
					                	                	 xtype  :'hidden',
					                	                	 id     :'categoryId',
					                	                	 width	: 30,
					                	                	 value  :'0'
					                	               },
					                	               { xtype :'displayfield', value :'Priority:',width:'90'},
				                	                   {
				                	                	    xtype         :'combo',
				                	                	    id            :'issuePriority',
				                	                	    value         : 'SELECT',
				                	                	    store         : issuePriorityStore,
					     		   		     		    	displayField  : 'name',
					     		   		     		    	valueField    : 'id',
					     		   		     		    	triggerAction : 'all',
					     		   		     		    	typeAhead     :false,
					     		   		     		    	width		  : 165.5,
					     		   		     		        editable	  : false,
					     		   		     		        listeners      :{select:function(){
				                	                	                        bindValue('issuePriority','issuePriorityId');
				                	                                         }
				                	                                        }
					     		   		     		        
					     		   		                 },
					     		   		                 {
						     		   		     		    	xtype  : 'hidden',
						     		   		     		    	id     :'issuePriorityId',
						     		   		     		    	value  :'0'
						     		   		     		 },
					     		   		                 
				                	                   
				                	                 ]
				                  },
				                  {
				            	       xtype        : 'compositefield',
				            	       fieldLabel   : 'ModuleId',
				            	       items        : [
														 {
																 xtype        : 'textfield',
																 id           : 'issueModule', 
																 width        :'156.5'
														  },
				            	                          { xtype :'displayfield', value:'Complexity:', width:'90'},
				            	                          {
				            	                        	   xtype          : 'combo',
				            	                        	   id             : 'complexity',
				            	                        	   value          : 'SELECT',
				            	                        	   store          : issueComplexityStore,
						     		   		     		   	   displayField   : 'name',
						     		   		     		   	   valueField     : 'id',
						     		   		     		   	   triggerAction  : 'all',
						     		   		     		   	   typeAhead      : false,
						     		   		     		   	   width		  : 164,
						     		   		     		       editable	      : false,
						     		   		     		       listeners      : {select:function(){
		   	                    	                                              bindValue('complexity','complexityId');
		   	                                                                                      }
		   	                                                                      }
						     		   		     		   },
				            	                           {
				            	                        	   xtype          :'hidden',
				            	                        	   id             :'complexityId',
				            	                        	   value          :'0'
				            	                           }
				            	                        ]
				                      },
				                      {
					            	       xtype        : 'compositefield',
					            	       fieldLabel   : 'Created By',
					            	       items        : [
															 {
																	 xtype        : 'textfield',
																	 id           : 'createdBy', 
																	 width        : '156.5'
															  },
															  {xtype: 'displayfield', value: 'Date: ', width:'90'},
			   				                	              {
			   									     		    	xtype		  : 'datefield',
			   									     		   	 	id			  : 'date',
			   									     		   	 	width		  : 165,
			   									     		   	 	format		  : 'Y-m-d',
			   									     		   	    value		  : '0'
			   									     		   },
					            	                          
					            	                        ]
					                  },
				                      {
        	                        	    xtype         : 'combo',
        	                        	    fieldLabel    : 'Assigned To',
        	                        	    id            : 'assignedTo',
        	                        	    value         : 'SELECT',
        	                        	    width         : '170',
        	                        	    store         : assignedToStore,
	     		   		     		    	displayField  : 'name',
	     		   		     		    	valueField    : 'id',
	     		   		     		    	triggerAction : 'all',
	     		   		     		    	typeAhead     : false,
	     		   		     		         editable	  : false,
	     		   		     		         listeners     :{select:function(){
        	                    	                          bindValue('assignedTo','assignedToId');
        	                                               }
        	                                              }
	     		   		     		       
        	                          },
        	                          {
	                	                	 xtype  :'hidden',
	                	                	 id     :'assignedToId',
	                	                	 value  :'0'
	                	             },
	                	             {
	   			                	  xtype      :'compositefield',
	   			                	  fieldLabel : 'Status',
	   			                	  items      : [
	   			                	                  {
	   			                	                	    xtype         : 'combo',
	   			                	                	    id            : 'issueStatus',
	   			                	                	    value         : 'SELECT',
	   			                	                	    width         : '170',
	   			                	                	    store         : issueStatusStore,
	   				     		   		     		   	 	displayField  : 'name',
	   				     		   		     		   	 	valueField    : 'id',
	   				     		   		     		   	 	triggerAction : 'all',
	   				     		   		     		   	 	typeAhead     : false,
	   				     		   		     		        editable	  : false,
	   				     		   		     		        listeners     :{select:function(){
	   			                	                	                             bindValue('issueStatus','issueStatusId');
	   			                	                                                     }
	   			                	                                        }
	   				     		   		     		    },
	   				     		   		     		    {
	   				                	                	 xtype        :'hidden',
	   				                	                	 id           :'issueStatusId',
	   				                	                	 width	      : 30,
	   				                	                	 value        :'0'
	   				                	                },
	   				                	                {xtype: 'displayfield', value: 'Target Date: ', width:'90'},
	   				                	                {
	   									     		    	xtype		  : 'datefield',
	   									     		   	 	id			  : 'targetDate',
	   									     		   	 	width		  : 165,
	   									     		   	 	format		  : 'Y-m-d',
	   									     		   	    value		  : '0' 
	   									     		     },
	   				                	                
	   				     		   		     		    
	   				     		   		             ]
	   			                 },
	   			                {
	   		                	  xtype      :'compositefield',
	   		                	  fieldLabel : 'Resolution',
	   		                	  items      : [
	   		                	                  {
	   		                                               xtype         : 'combo',
	   						                        	   fieldLabel    : 'Resolution',
	   						                        	   id            : 'resolution',
	   						                        	   value         : 'SELECT',
	   						                        	   store         : issueResolutionStore,
	   							   		     		   	   displayField  : 'name',
	   							   		     		   	   valueField    : 'id',
	   							   		     		   	   triggerAction : 'all',
	   							   		     		   	   typeAhead     : false,
	   							   		     		   	   width		 : 165, 
	   							   		     		        editable	 : false,
	   							   		     		       listeners     :{select:function(){
	   					       	                                           bindValue('resolution','resolutionId');
	   					                                                  }
	   					                                              }
	   							   		     		  },
	   						                          {
	   						                        	  xtype :'hidden',
	   						                        	  id    :'resolutionId',
	   						                        	  value :'0'
	   						                          },
	   						                          {xtype: 'displayfield', value: 'Date Resolved: ', width:'90'},
	   								     		      {
	   								     		    	xtype		  : 'datefield',
	   								     		    	id			  : 'dateResolved',
	   								     		   	 	width		  : 165,
	   								     		   	 	format		  : 'Y-m-d',
	   								     		    	value		  : '0'
	   								     		     }
	   			                                  ]
	   			                 },
	   			                 { 
				                	 xtype         : 'textarea',
				                	 id            : 'comment', 
				                     fieldLabel    : 'Comment',
				                     align         : 'top',
				                	 width         :  '421',
				                	 emptyText     :'Enter Comment here',
				                	 height        :  70
				                 }
	   			          ]
		  };
		  var issueUpdateRootPanel = {
	               xtype       : 'fieldset',
	               id          : 'issueUpdateRootPanel',
	               height      :  360, 
	               width       :  600,
	               frame       : true,
	               items       : [issueUpdate],
	               tbar        : {
	                               xtype       : 'toolbar',
	                               items       : [
													{
														xtype	: 'displayfield',
														id		: 'issueNameDisplay',
														align   : 'left',
														width	: 415
														
													},
	                                                {
													    xtype  : 'button',
													    text   : 'Save', 
													    id     : 'updateButton',
													    handler: function(){
														            var actionValue = Ext.getCmp('updateButton').getText(); 
														            addUpdateIssues(issueCommentStore);
														            
																}
												    },'-',
											        {
		    	                                       xtype   : 'button',
		    	                                       text    : 'Print',
		    	                                       id      :'printButton',
		    	                                       handler : function(){ window.print();}  
		    	                                    },'-',
		    	                                    {
	    	                                    	      xtype   : 'button',
	    	                                    	      text    : 'Cancel',
	    	                                    	      id      :'cancelButton',
	    	                                    	      handler : closeIssueUpdateWin
	    	                                       }
	    	                                      ]
	                             }
	                             
		  
	           };
		  
		var issueUpdateMainPanel = new Ext.FormPanel({
			  id     : 'issueUpdateMainPanel',
			  height :  430, 
			  frame  : true, 
              width  :  600,
			  items	 : [issueUpdateRootPanel]
	  });
			
		var commentPanel = {
				  xtype	: 'fieldset',
				  id    : 'commentPanel',
				  title : 'Issue Comments',
				  collapsible: false,
				  height : 300,
				  width :  600, 
				  autoScroll: true,
			      items	:  [
			         	   {
					            
							xtype     : 'dataview',
							tpl	      : tpl,
							store     :issueCommentStore,
							itemSelector: 'div.search-item'
				         }
				        	 
			         	    
			         	   ],
			        bbar: new Ext.PagingToolbar({
			        	 
			            store: issueCommentStore , 
			            pageSize: 10,
			            displayInfo: true,
			            displayMsg: 'Topics {0} - {1} of {2}',
			            emptyMsg: 'No topics to display'
			                  
			              })
			   };
		

		  
			  var combinePanel = new Ext.FormPanel({
					  xtype	 : 'panel',
					  id     : 'combinePanel',
					  frame  : true,
			          height : 600,
					  width  : 620,
					  items	 : [issueUpdateRootPanel,commentPanel]
			  });
			  
			  issueUpdatewin = new Ext.Window({
	   		   id          : 'issueUpdateWindow',
	   		   title       : 'Updated IssueComments',
	   		   iconCls     : 'AddComment',
	   		   width       : 620,
	   		   height      : 700,
	   		   layout      : 'fit',
	   		   frame       : true,
	   		   border      : false,
	           plain       : false,
	           closable    : true,
	           collapsible : true,
	           animCollapse: false,
	           draggable   : false,
	           maximizable : true,
	           onEsc	   : true,
	           model	   : true,  
	          items        : [combinePanel]
	          	});
			  issueUpdatewin.show(this);
			  var issId = Ext.getCmp('issueId');
			  var issueProId = Ext.getCmp('issueProjectId');
		      issueProId.setValue(issId.getValue()); 
		      showIssueCommentDetails(issueRowData);
		      disableIssueUpdateForm();
		      displayIssueName(issueRowData);
	   		  return issueUpdatewin; 
   	};
   	
   	function closeIssueUpdateWin(){
   		issueUpdatewin.close();
   	}
   	
   	function showIssueCommentDetails(issueRowData){
      var issueId =  issueRowData.get('issueId');
	   var formPanel = Ext.getCmp('combinePanel'); 
 	    var values = formPanel.getForm().getValues();
 	    var encoded = Ext.encode(values);
 	    formPanel.getForm().load({
 			method  : 'GET',
 	            url     : 'issueComment/showIssueCommentDetailsInPopup?issueId='+issueId,
 	      		success : function() {
 	      					formPanel.el.unmask();
 	            			},
 	            failure:function() { 
 	                		alert ("Failure"); 
 	                		formPanel.el.unmask();
 	               			}
 			});

 		};
 		
   function addUpdateIssues(iCStore){
	     
	   var issueId = Ext.getCmp('issueId').getValue();  
	   var formPanel = Ext.getCmp('combinePanel');
	   var values = formPanel.getForm().getValues();
	   var encoded = Ext.encode(values);
	   Ext.Ajax.request({
	        		   url		: 'issueComment/save?issueId='+issueId,
	        		   method	: 'POST',
	      	            success : function(result, request) {  
	  	        		         alert("Comment Updated Successfully.");  
	  	        		         iCStore.reload(); 
	  	        		         var issueHomeGrid=Ext.getCmp('issueHomeGrid');
	  	        		         issueHomeGrid.store.reload();
	  	        		         var  IssueMine = Ext.getCmp('myIssueGrid');
	  	        		         IssueMine.store.reload();  
	  	         },
	      	   failure: function() { alert ("Failure"); },
	      	   jsonData: encoded  
	      	}); 
	  };

   function disableIssueUpdateForm(){
 			
	        Ext.getCmp('issueReason').disable();
	        Ext.getCmp('category').disable();
	        Ext.getCmp('issuePriority').disable();
	        Ext.getCmp('issueModule').disable();
	        Ext.getCmp('complexity').disable();
	        Ext.getCmp('createdBy').disable();
	        Ext.getCmp('date').disable();
 			Ext.getCmp('assignedTo').enable();
 			Ext.getCmp('issueStatus').enable();
 			Ext.getCmp('resolution').enable();
 			Ext.getCmp('targetDate').disable();   
 			Ext.getCmp('dateResolved').enable(); 
 			Ext.getCmp('comment').enable(); 
 			Ext.getCmp('updateButton').enable();
 		};
 	
 		function displayIssueName(rowData){
 	 		var issueNameValue  = rowData.get('issueName');
 	 		Ext.getCmp('issueNameDisplay').setValue("<b>&nbsp" + issueNameValue + "</b>");  
 	 	}

   
